/*
*@成都小C
* 路由初始化
*
*
*
*/

import React from 'react';
import {HashRouter, Route, Switch} from 'react-router-dom';
import routes from './router';
import { createHashHistory } from 'history';
const history = createHashHistory();
const BasicRoute = () => (
    <HashRouter history={history}>
        <Switch>
            {
               routes.map((item,index)=>{
                    if(item.children){
                        return <Route key={index} exact={item.exact} path={item.path} render={()=>
                                        <item.component>
                                            {
                                                item.children.map((v,k)=>{
                                                    return <Route key={k} exact={v.exact} path={v.path} component={v.component}/>
                                                })
                                              
                                             }
                                        </item.component>
                                }/>
                         
                    }else{
                       
                        return <Route key={index} exact path={item.path} component={item.component}/> 
                    }
                    
                })
            }
        </Switch>
    </HashRouter>
)
export default BasicRoute